<%--
 *  File:    AgreementModelUpload.jsp
 *  @Author: yuan
 *  Date:    1/25/2016 13:45
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/oval-tag.tld" prefix="oval" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%@ page import="com.oval.foundation.DefaultParams" %>

<%
  	Category cat = Category.getInstance("jsp.AgreementModelUpload");
  	//init param
  	String strTableName = "v_agreementmodel";
  	String strModuleName = "CRM";
    String privilegeCode = "11208";
    String contextPath = request.getContextPath();
%>
<%
  	HashMap userInfo = (HashMap)session.getAttribute("userinfo");

%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>

<head>
<title>AgreementModelUpload</title>
<PageFlow:CheckPageFlow pageName="p_agreementmodel"/>

<%
Vector totalsummary = (Vector) pageContext.getAttribute("totalsummary");
if (totalsummary == null)
    totalsummary = new Vector();
%>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath%>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/keyFunction.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/ScriptLib.js"></script>
<%@ include file="/inc/SummaryDivision.inc" %>
<script language="JavaScript" src="<%=contextPath%>/js/SummaryDivision.js"></script>

<script>

function page_operate(){
	if(cform.picture.value === "" || cform.picture.value === null){
		return false;
	}
	
	if(!checkForm(document.cform))return;
    //文件路径 、校验格式
    
	var pname = ""+cform.picture.value;
    if (pname==""){
      alert(replaceString("<%=message.getMessageDesc("VALUE_NOT_NULL")%>","%s","<%=label.getLabelName("L_Maccessory")%>".replace("\'","'")));
      cform.picture.focus();
      return;
    }
    
    var iLastPoint=pname.lastIndexOf(".");
    if(iLastPoint!=-1)
	   cform.filesuffix.value=pname.substring( iLastPoint+1,pname.length);
	  var iLastPoint1=pname.lastIndexOf("\\");
     if(iLastPoint1!=-1)
     cform.picturestr.value=pname.substring( iLastPoint1+1,iLastPoint)+"<%=Calendar.getInstance().getTimeInMillis()   %>";
    var re = /.txt$|.doc$|.docx$|.xls$|.xlsx$|.vsd$|.pdf$|.ppt$|.zip$|.rar$|.bmp$|.jpg$|.jpeg$|.tiff$|.gif$|.pcx$|.tga$|.exif$|.fpx$|.svg$|.psd$|.cdr$|.pcd$|.dxf$|.ufo$|.eps$|.ai$|.raw$/ig;
    if(pname.toUpperCase().match(re) == null)
    {
      alert("<%= message.getMessageDesc("ILLEGAL_FORMAT",label.getLabelName("L_Maccessory",false)) %>");
      return;
    }  
    if (pname.indexOf("\\")!=-1)
      pname = pname.substring(pname.lastIndexOf("\\")+1,pname.length);
    //文件名称
    if (cform.picturename.value=="")
      cform.picturename.value = pname;
    if(cform.picturename.value.toUpperCase().match(re) == null)
    {
      if(pname.lastIndexOf(".") != -1)
        cform.picturename.value += pname.substring(pname.lastIndexOf("."));
      <%--[SCRIPT]  alert("<#%= message.getMessageDesc("ILLEGAL_FORMAT",label.getLabelName("L_Picture",false)) %#>");  [SCRIPT]--%>
      <%--[SCRIPT]  return;  [SCRIPT]--%>
    }  
    if (getLength(cform.picturename.value)>64)
    {
		    alert("<%= message.getMessageDesc("LENGTH_MUST_NOT_EQUAL", label.getLabelName("L_Name",false),"64") %>" );
		    return;
    }
	
     cform.actionname.value = "upload";
     cform.target = "_self";
   	 isRunning = true;
   	 cform.submit();
}

function selectFile()
{
  var val = cform.picture.value;
  var fn = val.substring(val.lastIndexOf('\\')+1,val.length);
  if(fn.length == val.length)
    fn = val.substring(val.lastIndexOf('\/')+1,val.length);
  cform.picturename.value=fn;
}

</script>
</head>
<body>

	<%--------------------------------------  hidden form variant   --%>
	<form name="cform" method="post" action="../../Dispatcher" ENCTYPE="multipart/form-data">
	<%@ include file="/inc/PageLocation.inc" %>

    <input type="hidden" name="pagename" value="p_agreementmodel">
    <input type="hidden" name="actionname">
    <input type="hidden" name="languagecode" value="<%= strLanguageCode %>"> 
    <input type="hidden" name="userid" value="<%=JspHelper.filterNull(userInfo.get("userid"))%>">
    
    <input type="hidden" name="uploadpath" value="Y:/"/>
    <custom:hidden  property="filesuffix"/>
    
    <table width="100%" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td>
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
					<tr>
						<td class="summary_top" ></td>
					</tr>
					<tr >
						<td class="td_left">
							<%= label.getLabelName("L_Path") %><%= label.getLabelName("L_Colon") %>
							<input type="file" name="picture" size="30" onclick="javascript:picture.focus()" onfocus="javascript:selectFile()" >
						    &nbsp;&nbsp;&nbsp;
						    <a onclick="page_operate()"><custom:button type="1" label="L_Finish" imgsrc="finish.gif" border="0" style="width:60"/></a>
						    <input type="hidden" name="picturename" >
						    <input type="hidden" name="picturestr" >
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	
</form>
</body>


</html>


